﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Manage/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QianBuo.Lottery.Web.Areas.Manage.Models.Site.OptionModel>" %>
<%@ Import Namespace="Code.Models" %>
<%@ Import Namespace="QianBuo.Lottery.Web.Areas.Manage.Models.Site" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	系统设置
</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<% Html.DisableClientValidation(); %>
<% Html.BeginForm( new { id="OptionForm"},null); %>
    <fieldset>
    <legend>系统设置</legend>
    <div>
     <ul class="editlist">
        <% foreach (var item in Model.Options){
          var enumItem = item.Key.GetDetail();
          var value = item.Value; var tp = MvcHtmlString.Empty;
          switch (enumItem.Type) { 
              case ControlType.TextBox:
                  tp = Html.TextBox(value.Key, value.Value, new { @clas = "text50", validate = item.Key.GetJQueryValidate(enumItem.IsNull ? "" : "required:true") });
                  break;
              case ControlType.CheckBox:
                  tp = Html.CheckBox(value.Key, "True".Equals(value.Value as string, StringComparison.CurrentCultureIgnoreCase), new { validate = item.Key.GetJQueryValidate(enumItem.IsNull ? "" : "required:true") });
                  break;
              case ControlType.Password:
                  tp = Html.Password(value.Key, "", new { @clas = "text50", validate = item.Key.GetJQueryValidate(enumItem.IsNull ? "" : "required:true") });
                  break;
              case ControlType.HtmlBox:
                  tp = Html.ActionLink("点击设置", "OptionHtml", new { id = item.Key,act="Option",cont="Site" }, new { @class = "a_blue" });
                  break;
              default:
                  continue;
          }%>
            <li class="title_setuser">
                <label class='width140 label' for='<%=value.Key %>'><%=enumItem.Name%>:</label>
                <span class="spans">
                    <%=tp %>
                    <%=Html.ValidationMessage(item.Value.Key) %>
                    <label><%=enumItem.Remark %></label>
                </span>
            </li>
            
            
       <%
	    } %>
        <li class="btn">
            <input type="submit" value='保存' />&nbsp;&nbsp;<input type="reset" value="重设" />
        </li>
    </ul>
    </div>
</fieldset>
<%=Html.SerializableFor(p=>p.OldOptions) %>
<% Html.EndForm(); %>
</asp:Content>


<asp:Content ID="Content3" ContentPlaceHolderID="StyleAndScript" runat="server">
<style type="text/css">
    .titleli{ color:Blue; }
</style>
<script type="text/javascript" src='<%=Url.Content("/Scripts/jquery.form.js") %>'></script>
<script src='<%=Url.Content("/Scripts/jquery.metadata.js") %>' type="text/javascript"></script>
<script src='<%=Url.Content("/Scripts/jquery.validate.errormsg.js") %>' type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        //$('#OptionForm').validate();
        $('#OptionForm').ajaxForm({
            beforeSubmit: function (formData, jqForm, options) {
                var valid = jqForm.valid();

                return valid;
            },
            success: function (result) {
                if (result.errors.length) {
                    for (var i in result.errors) {
                        var item = result.errors[i];
                        var doc = $("#" + item.Name).addClass("error");
                        var lbl = doc.next();
                        if (lbl.is(".error"))
                            lbl.text(item.Error)
                        else
                            doc.after("<label for='" + item.Name + "' class='error'>" + item.Error + "</label>");
                    }
                }
                else if (result.msg.length)
                    alert(result.msg);
                if (result.count && result.count > 0)
                    location.href = location.href;
            }
        });
        $("#OptionForm li.titleli").css({ cursor: 'pointer' }).click(function () {
            $("#OptionForm .title_" + this.id).toggle(500);
        });
        $(".width140").css({ width: "140px" });
        $(".spans").css({ width: "580px" });
    });
</script>
</asp:Content>
